{include file="public/nheader"}
<div class="layui-fluid">
    <div class="layui-card">
        <!-- // 默认操作按钮 -->
        <div class="layui-card-header layadmin-card-header-auto ">
            <div class="layui-form">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-input-inline ">
                            <select name="status" lay-verify="">
                                <option value="">状态</option>
                                <option value="1" {if !empty(input('get.status')) &&
                                    input('get.status')==1}selected{/if}>进行中</option>
                                <option value="2" {if !empty(input('get.status')) &&
                                    input('get.status')==2}selected{/if}>暂停</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline ">
                            <input name="title" class="layui-input" type="text" placeholder="活动名称" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <!-- // 默认搜索 -->
                        <button class="layui-btn icon-btn" lay-filter="formSearch" lay-submit>搜索</button>
                        <!-- // 打开添加页面 -->
                        <button class="layui-btn icon-btn" lay-maxmin="true" lay-open="" data-title="添加"
                            data-area="60%,80%" data-url="/agent/promo_edit">添加
                        </button>
                    </div>
                </div>
            </div>
        </div>
        <!-- // 创建数据实例 -->
        <table id="lay-tableList" lay-filter="lay-tableList"></table>
    </div>
</div>

<script type="text/html" id="datagrid-toolbar">
</script>
<!-- // 列表工具栏 -->
<script type="text/html" id="tableBar">
    <a class="layui-table-text" lay-open data-title="领取详情" data-area="80%,90%" data-url="/user/coupon?promo={{d.id}}" >领取详情</a>
    <div class="layui-divider layui-divider-vertical"></div>
    <a class="layui-table-text" lay-open data-title="获取二维码" data-area="80%,90%" data-url="/agent/promo_alert?id={{d.id}}" >获取二维码</a>
    <div class="layui-divider layui-divider-vertical"></div>
    <a class="layui-table-text" lay-open data-title="编辑" data-area="60%,80%" data-url="/agent/promo_edit?id={{d.id}}" >编辑</a>
</script>

{include file="public/nfooter"}
<script>
    layui.use(['table'], function () {
        var table = layui.table;
        /*
         * 初始化表格
        */
        var isTable = table.render({
            elem: "#lay-tableList"
            , url: "{:url()}"
            , page: true
            , size: 'lg'
            , even: true
            , cols: [[
                { type: 'checkbox', width: 60 },
                { field: 'id', align: 'center', sort: true, width: 80, title: 'ID' },
                { field: 'title', width: 200, align: 'center', title: '活动' },
                { field: 'agent_name', width: 200, align: 'center', title: '代理' },
                { field: 'people', width: 100, align: 'center', title: '发放人数' },
                { field: 'peoples', width: 100, align: 'center', title: '已领取人数' },
                { field: 'sxtime', width: 200, align: 'center', title: '结束时间' },
                {
                    field: 'status', align: 'center', width: 120, templet: function (d) {
                        if (d.status == 1) {
                            return '进行中';
                        }
                        return '结束';
                    }, title: '状态'
                }, { align: 'center', width: 250, toolbar: '#tableBar', title: '操作' },
            ]]
        })
    })
</script>